<template>
    <el-breadcrumb separator="/" class="breadcrumb">
        <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item v-for="(item,index) in routeArr" :key='index'>{{item}}</el-breadcrumb-item>
    </el-breadcrumb>
</template>
<script>
export default {
    data(){
        return{
            routeArr:[]
        }
    },
    watch:{
        $route:{
            handler(route){
                if(route.path=='/index'){
                this.routeArr=[]
                return
                }
            let routeArr =route.matched.map(item=>item.meta.title)
            this.routeArr=routeArr
            }
        }
    }



};
</script>
<style scoped>
.breadcrumb{
    margin: 20px;
}
</style>>
